<?php
include("../UserIncludes/DbConfig.php");
 $id=$_REQUEST['id'];

/*
---------Fetch and show add---------

For showing the add frist fetch data from adspace_details and advertise_master where adspaceIdMd=requested id.
then take the adspaceId from adspace_details and check from advertise_details table if the networkId is 0 or not.

1.If network id is 0 (means this is a direct add) then take the adspaceId.
then take the style, color, width, height, etc from adspace_details matching that adspaceId

use this as the style in the below table. and show all data from advertise_details , advertise_master where adspaceId is equal to requested id.

2. If network id is != 0 (means this is a network add) then take the networkId and find category id from network table.and find the highest bidder and using this category id find adsiteId from adsite_master and using this adsiteId from adspace_master find how meny space are involve with this adsiteId and and find clickPerDay. and 
finally show that highest bidder's advertise into the highest clikable publisher's site. 

*/


// This query is only for direct ADS but not for custom ads.......

   //$sql_advertise="select * from adspace_details where adspaceIdMd='".md5(39)."' ";
echo  $sql_advertise="select * from advertise_details AD, adspace_details SD,advertise_master AM where AD.adspaceId=SD.adspaceId and AD.advertiseId=AM.advertiseId and SD.adspaceIdMd='".md5(39)."' and AM.advertiseStatus = 'Y' and AM.startDate <= '".date('Y-m-d')."' and AM.endDate >= '".date('Y-m-d')."' and AD.networkId = 0 ";

	 $query_advertise=mysql_query($sql_advertise);
	$rec=mysql_fetch_array(mysql_query($sql_advertise));
?>
<table class="center" cellspacing="7" cellpadding="0" border="0">
<tr>

<?php
		
	 $size=$rec['adSize'];
$adSize=explode('x',$rec['adSize']);
// echo $adSize['0'];


//echo $bodyColor;
$backgroundColor='#E8E8E8';

?>
<td align="left">

		<table width="<?php echo $adSize['0'];?>" border="0" cellspacing="0" cellpadding="0" bgcolor="<?php echo $backgroundColor;?>" height="<?php echo $adSize['1'];?>">
              <tr>
                <td align="center">
					<a href="<?php echo $row_advertise[destinationUrl];?>" style="font-family: <?php echo $fontType;?>; color:<?php echo $headerColor;?>;">
					
					<?php
					echo $row_advertise[adTitle];
					?>
					</a>
                </td>
               </tr>

			 <tr>
                <td style="padding-left:20px;">
					<font color="<?php echo $bodyColor;?>" style="font-family: <?php echo $fontType;?>;">
					<?php
					echo $row_advertise[adTitle];
					?>
					</font>
                </td>
               </tr>

        </table>
		
	</tr>
</table>

